package com.swk.user.controller;

import com.swk.common.controller.BaseController;
import com.swk.user.bean.User;
import com.swk.user.service.UserService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * http://127.0.0.1:8081/user/getList
 * Created by Administrator on 2018-4-17.
 */
@Controller
@RequestMapping("/")
public class UserController extends BaseController {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private UserService userService;

    @RequestMapping("/getUserList")
    @ResponseBody
    List<User> get(HttpServletRequest request,@RequestParam String id) {
        logger.info("enter get 时间戳：{} ",  System.currentTimeMillis());

        if (StringUtils.isBlank(id)) {
            return  new ArrayList<User>();
        }

        Map<String, Object> map = new HashMap();
        map.put("id", id);
        List<User> users =  (List<User>)userService.getList(map);

        logger.info("left get 时间戳：{} ",  System.currentTimeMillis());
        return users;
    }
}
